package controller

import (
	"Gin/app/service"
	"Gin/app/vo"
	"Gin/config"
	"github.com/gin-gonic/gin"
	"net/http"
)

type RootController struct {
}

var RootOperate service.RootService

func (r *RootController) Login(c *gin.Context) {
	loginVo := &vo.LoginVo{}
	err := c.BindJSON(loginVo)
	if err != nil {
		vo.FAIL(nil, config.ServerBusy, http.StatusInternalServerError, c)
		return
	}
	RVo := RootOperate.Login(loginVo)
	if RVo == nil {
		vo.FAIL(nil, config.LoginFailForUserNameOrPassword, http.StatusInternalServerError, c)
		return
	}
	vo.OK(RVo, config.LoginSuccess, http.StatusOK, c)
}
